package com.create.singleton;

/**
 * DCL-懒汉式的一种(延迟加载，安全，比较复杂)
 *
 * @author xiaobing
 * @version 1.0
 * @date 2021/9/6 2:22 下午
 */
public class DCLSingleton {
    private static volatile DCLSingleton dclSingleton;

    public DCLSingleton() {
    }

    public static DCLSingleton getInstance() {
        if (dclSingleton == null) {
            synchronized (DCLSingleton.class) {
                if (dclSingleton == null) {
                    return new DCLSingleton();
                }
                return dclSingleton;
            }
        }
        return dclSingleton;
    }
}
